package main

import "fmt"

func uniquePaths(m int, n int) int {
	if m == 1 || n == 1 {
		return 1
	}
	var result [][]int
	for x := 0; x < m; x++ { //循环为一维长度
		arr := make([]int, n)        //创建一个一维切片
		result = append(result, arr) //把一维切片,当作一个整体传入二维切片中
	}
	for i := 0; i < m; i++ {
		result[i][0] = 1
	}
	for i := 0; i < n; i++ {
		result[0][i] = 1
	}
	for i := 1; i < m; i++ {
		for j := 1; j < n; j++ {
			result[i][j] = result[i-1][j] + result[i][j-1]
		}
	}
	return result[m-1][n-1]
}

func main() {
	fmt.Println(uniquePaths(3, 7))
}
